<!DOCTYPE html>
<html>
<head>
	{include file="common_header" /}
	{include file="common_top" /}
	<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">修改任务</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">


           <div class="layui-form-item">
            <label class="layui-form-label">平台选择</label>
            <div class="layui-input-block">
				{volist name="task_platform" id="vo" key="k"}
              <input type="radio" name="tpf_id" value="{$vo.tpf_id}" title="{$vo.tpf_title}" {if $info['tpf_id']==$vo.tpf_id}checked=""{/if}>
              {/volist}
            </div>
          </div>  
		  
		   <div class="layui-form-item">
            <label class="layui-form-label">类型选择</label>
            <div class="layui-input-block">
			{volist name="task_type" id="vo" key="k"}
              <input type="radio" name="tt_id" value="{$vo.tt_id}" title="{$vo.tt_title}" {if $info['tt_id']==$vo.tt_id}checked=""{/if}>
              {/volist}
            </div>
          </div> 
		  
          
          <div class="layui-form-item">
            <label class="layui-form-label">店铺名称</label>
            <div class="layui-input-block">
              <input type="text" name="dpname" id="dpname"   placeholder="店铺名称" class="layui-input" value="{$info['t_dp_name']}">
            </div>
          </div>
		  
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">链接网址</label>
            <div class="layui-input-block">
              <input type="text" name="url" id="url"   placeholder="链接网址" class="layui-input" value="{$info['t_url']}">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">任务数量</label>
            <div class="layui-input-block">
              <input name="title" type="text" disabled class="layui-input" id="title" value="{$info['t_count']}" readonly="readonly"   placeholder="任务数量">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">任务单价</label>
            <div class="layui-input-block">
              <input name="title" type="text" disabled class="layui-input" id="title" value="{$info['t_money']}" readonly="readonly"   placeholder="任务单价">
            </div>
          </div>
		  
		   <div class="layui-form-item">
            <label class="layui-form-label">任务总价</label>
            <div class="layui-input-block">
              <input name="title" type="text" disabled class="layui-input" id="title" value="{$info['t_z_money']}" readonly="readonly"   placeholder="任务单价">
            </div>
          </div>
		  
		  
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">任务描述</label>
            <div class="layui-input-block">
              <script id="editor" type="text/plain" style="width:100%;height:300px;"></script>
            </div>
          </div>
		  

          <div class="layui-form-item">
            <label class="layui-form-label">任务状态</label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="1" title="待审" {if $info['t_status']==1}checked=""{/if}>
              <input type="radio" name="status" value="2" title="发布" {if $info['t_status']==2}checked=""{/if}>
			  <input type="radio" name="status" value="2" title="完结" {if $info['t_status']==3}checked=""{/if}>
            </div>
          </div>       
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <div class="layui-btn sub">立即提交</div>
                <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{include file="common_footer" /} 
<script>
var ue = UE.getEditor('editor');
$(document).ready(function () {
    ue.ready(function () {
        ue.setContent('{$info['t_desc']}');
    });
});
$(".sub").click(function(){
	var tpf_id = $("input[name='tpf_id']:checked").val();
	var tt_id  = $("input[name='tt_id']:checked").val();
	//var title  = $("#title").val();
	var dpname  = $("#dpname").val();
	var url    = $("#url").val();
	var editor = UE.getEditor('editor').getContent();
	var status  = $("input[name='status']:checked").val();

	
	if(tpf_id ==""){
		show_error("平台不能为空，请先选择！");
		return false;
	}
	
	if(tt_id ==""){
		show_error("类型不能为空，请先选择！");
		return false;
	}

	
	if(dpname ==""){
		show_error("店铺名称不能为空！");
		return false;
	}
	

	$.ajax({
		type:"POST",
		url:"{:url('task/edit')}",
		dataType:"json",
		data:{
			id:{$info['t_id']},
			tpf_id:tpf_id,
			tt_id:tt_id,
			dpname:dpname,
			url:url,
			editor:editor,
			status:status,
		},
		success:function(res){
			if(res.status == "success"){
				show_toast_callurl(res.data,"{:url('task/index')}","success");
			}else{
				show_error(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
</body>
</html>
